package cn.wu.reggie.mapper;

import cn.wu.reggie.entity.Category;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface CategoryMapper {

    @Select("select * from category order by sort desc")
    List<Category> findAll();

    @Insert("insert into category values(null,#{type},#{name},#{sort},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void save(Category category);

    @Update("update category set name = #{name},sort = #{sort},update_time=#{updateTime},update_user = #{updateUser} where id = #{id}")
    void update(Category category);

    @Delete("delete from category where id = #{id}")
    void delete(Long id);


    List<Category> findAllByType(Integer type);
}
